<template>
	<view>
		<view class="" style="padding: 26rpx 30rpx 0rpx ;">
			<view class="" style="padding-bottom: 36rpx;">
				<x-cell :leftslot="true" :rightslot="true">
					<view class="d-flex" slot="lefttext">
						<view class="" style="margin-right: 38rpx;">
							昵称:
						</view>
						<view class="">
							<input type="text" :placeholder="userinfo.nickname" v-model="nickname" />
						</view>
					</view>
				</x-cell>
			</view>
			<u-line color="info" border-style="solid" />
			<view class="" style="padding: 26rpx 0rpx 34rpx;">
				<x-cell :leftslot="true" :rightslot="true">
					<view class="d-flex" slot="lefttext">
						<view class="" style="margin-right: 38rpx;">
							性别
						</view>
						<view class="">
							<input type="text" :placeholder="userinfo.sex" v-model="sex" />
						</view>
					</view>
				</x-cell>
			</view>
			<u-line color="info" border-style="solid" />
		</view>
		<view class="" style="margin-top: 106rpx;">
			<x-button title="保存信息" @btnClick='getTophone'></x-button>
		</view>
	</view>
</template>

<script>
	import {
		save
	} from '@/config/apiRouter.js'
	import {
		mapGetters
	} from 'vuex'
	export default {
		data() {
			return {
				nickname: '',
				sex: ''
			}
		},
		computed: {
			...mapGetters(['userinfo'])
		},
		onLoad() {
			this.nickname = this.userinfo.nickname;
			this.sex = this.userinfo.sex;
		},
		methods: {
			getTophone() {
				save({
					nickname: this.nickname,
					sex: this.sex,
				}).then(res => {
					this.$tool.codeStatus.apply(this)
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					uni.switchTab({
						url: '../../pages/my/my'
					})
				})
				console.log('保存信息')
			}
		}
	}
</script>

<style>

</style>
